package com.cskaoyan.user.controller;

import com.cskaoyan.mall.commons.result.ResponseData;
import com.cskaoyan.mall.commons.result.ResponseUtil;
import com.cskaoyan.user.constants.UserRetCode;
import com.cskaoyan.user.dal.entitys.UserVerify;
import com.cskaoyan.user.dto.UserVerifyRequest;
import com.cskaoyan.user.dto.UserVerifyResponse;
import com.cskaoyan.user.service.UserVerifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 类说明
 *
 * @author zhangfuqiang
 * @date 2022/5/19
 */
@RestController
public class UserVerifyController {

    @Autowired
    UserVerifyService userVerifyService;

    //http://localhost:8101/user/verify?uuid=3f3d929b89f45f730bf430d2aa6bf23d&username=cskaoyan01
    @GetMapping("/user/verify")
    public ResponseData userVerify(UserVerifyRequest userVerifyRequest){

        // 根据业务逻辑处理请求
        UserVerifyResponse response = userVerifyService.userVerify(userVerifyRequest);

        if (UserRetCode.SUCCESS.getCode().equals(response.getCode())) {
            // 业务方法调用成功
            return new ResponseUtil().setData(null);
        }

        // 业务方法执行失败
        return new ResponseUtil().setErrorMsg(response.getMsg());
    }
}
